//
//  ConsulationAnswerCellModel.m
//  EnvironmentalProtection
//
//  Created by HCreater on 2018/11/2.
//  Copyright © 2018年 HCreater. All rights reserved.
//

#import "ConsulationAnswerCellModel.h"

#import "ReplyListData.h"

@interface ConsulationAnswerCellModel ()

@property (nonatomic, copy) NSString* name;
@property (nonatomic, copy) NSString* content;
@property (nonatomic, copy) NSString* time;
@property (nonatomic, copy) NSString* imgurl;

@property (nonatomic, assign) BOOL isAdopt;
@property (nonatomic, assign) BOOL isAnswered;
@property (nonatomic, assign) BOOL isAskUser;

@end

@implementation ConsulationAnswerCellModel

- (instancetype)initWithData:(id)data cellHeight:(CGFloat)cellHeight
{
    self = [super init];
    if (self)
    {
        _data = data;
        
        ReplyListData* replyListData = _data;
        
        /// cellHeight+2（2容错）
        _cellHeight = MHUIScaleValue(cellHeight)+2;
        
        _name = replyListData.expert.nickName;
        _content = replyListData.content;
        _time = replyListData.addTime;
        _imgurl = replyListData.expert.headImg;
        _isAskUser = replyListData.isAskUser;
        _isAdopt = replyListData.isAnswer;
        _isAnswered = [replyListData.askStatus isEqualToString:@"2"];
        
        _focusCommand = [[RACCommand alloc] initWithSignalBlock:^RACSignal *(id input) {
            
            return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
                
                [subscriber sendNext:nil];
                [subscriber sendCompleted];
                
                return nil;
            }];
        }];
        
        _adoptCommand = [[RACCommand alloc] initWithSignalBlock:^RACSignal *(id input) {
            
            return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
                
                [subscriber sendNext:nil];
                [subscriber sendCompleted];
                
                return nil;
            }];
        }];
    }
    
    return self;
}

- (void)rebind:(id)data
{
    ReplyListData* replyListData = data;
    
    self.isAdopt = replyListData.isAnswer;
    self.isAnswered = [replyListData.askStatus isEqualToString:@"2"];
}

@end
